package com.ruoyi.common.core;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.ehcache.EhCacheCacheManager;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextClosedEvent;
import org.springframework.stereotype.Component;

@Component
public class CloseListener implements ApplicationListener<ContextClosedEvent> {

    @Autowired
    private EhCacheCacheManager cacheManager;

    @Override
    public void onApplicationEvent(ContextClosedEvent event) {
        cacheManager.getCacheManager().shutdown();
    }
}
